﻿using Autodesk.AutoCAD.Windows;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CADTool.TestTool
{
    public static class TrayItemTool
    {
        static string name = "YZQ-CADTool加载成功！";
        static string fileName = "logo.ico";
        static TrayItem trayItem = null;
        public static TrayItem GetTrayItem(this StatusBar statusBar)
        {
            if (trayItem == null)
            {
                for (int i = 0; i < statusBar.TrayItems.Count; i++)
                {
                    var ti = statusBar.TrayItems[i];
                    if (ti.ToolTipText == name)
                    {
                        trayItem = ti;
                        break;
                    }
                }
            }
            if (trayItem == null)
            {
                var icon = new Icon(fileName);
                trayItem = new TrayItem()
                {
                    ToolTipText = name,
                    Icon = icon,
                };
                statusBar.TrayItems.Add(trayItem);
                statusBar.Update();
            }
            return trayItem;
        }
    }
}
